//
//  MainTabViewController.m
//  ShiShiQiuSai_NBA
//
//  Created by 张宁宁 on 2018/1/22.
//  Copyright © 2018年 all. All rights reserved.
//

#import "MainTabViewController.h"
#import "TabbarView.h"
#import "HomeViewController.h"
#import "MessageViewController.h"
#import "MineViewController.h"
#import "SearchViewController.h"

@interface MainTabViewController ()<UITabBarControllerDelegate,TabBarViewDelegate>{
    TabBarView * tabbarView;
    HomeViewController * home;
    MessageViewController * message;
    MineViewController * mine;
    SearchViewController * search;
    UITabBarController * tabBarController;
}

@end

@implementation MainTabViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self createTabbar];
    [self.navigationController setNavigationBarHidden:YES];
}
//设置状态栏颜色为白色
- (UIStatusBarStyle)preferredStatusBarStyle {
    return UIStatusBarStyleLightContent;
}
- (void)createTabbar
{
    home = [[HomeViewController alloc]init];
    UINavigationController *mainNav = [[UINavigationController alloc]initWithRootViewController:home];
    [mainNav setNavigationBarHidden:YES animated:NO];
    
    search = [[SearchViewController alloc]init];
    UINavigationController *noticeNav = [[UINavigationController alloc]initWithRootViewController:search];
    [noticeNav setNavigationBarHidden:YES animated:NO];
    
    message = [[MessageViewController alloc]init];
    UINavigationController *workNav = [[UINavigationController alloc]initWithRootViewController:message];
    [workNav setNavigationBarHidden:YES animated:NO];
    
    mine = [[MineViewController alloc]init];
    UINavigationController *myNav = [[UINavigationController alloc]initWithRootViewController:mine];
    [myNav setNavigationBarHidden:YES animated:NO];
    
    
    tabBarController = [[UITabBarController alloc]init];
    tabBarController.selectedIndex = 0;
    [tabBarController.view setFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREENH_HEIGHT)];
    tabBarController.delegate=self;
    tabBarController.viewControllers=@[mainNav,noticeNav,workNav,myNav];
    [self.view addSubview:tabBarController.view];
    
    
    
    [self addChildViewController:tabBarController];
    tabbarView = [[TabBarView alloc]initWithFrame:CGRectMake(0, SCREENH_HEIGHT-[UIView getSuitableLength:49], SCREEN_WIDTH, [UIView getSuitableLength:49])];
    [tabBarController.view addSubview:tabbarView];
    tabbarView.tag=1000;
    tabbarView.tabbarDelegate=self;
    [tabbarView setCurrentIndex:0];
    [self.tabBarController.tabBar removeFromSuperview];
    
    
    
}
-(void)tabBarSelected:(NSInteger)index
{
    tabBarController.selectedIndex = index;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
